#include<vector>
#include<functional>
using namespace std;

namespace zzy
{
    template <class T, class Container = vector<T>, class Compare = less<T> >
    class priority_queue
    {
    public:
        priority_queue()
        {
            c.reserve(10);
        }

        template <class InputIterator>
        priority_queue(InputIterator first, InputIterator last)
        {
            c.reserve(last - first);
            for (auto it = first; it != last; ++it)
            {
                c.push_back(*it);
            }
            make_heap(c.begin(), c.end(), comp);
        }

        bool empty() const
        {
            return c.empty();
        }

        size_t size() const
        {
            return c.size();
        }

        T& top() const
        {
            return c.front();
        }

        void push(const T& x)
        {
            c.push_back(x);
            push_heap(c.begin(), c.end(), comp);
        }

        void pop()
        {
            pop_heap(c.begin(), c.end(), comp);
            c.pop_back();
        }

    private:
        Container c;
        Compare comp;
    };
};